import DrawBaseItem from './DrawBaseItem';
import {Rectangle} from 'pixi.js';

/**
 * 矩形
 *
 * RectangleItem
 * 
 * @extends DrawBaseItem
 * @class
 * @memberof Nice.DrawBase
 * @author iwangcj
 */
export default class RectangleItem extends DrawBaseItem 
{
    constructor(x=0, y=0, width=0, height=0) {
        super();

        /**
         * @member {Rectangle}
         * @default {0,0,0,0}
         */
        this.rectangle = new Rectangle(x,y,width,height);

    }


    get x() {
        return this.rectangle.x;
    }

    set x(_x) {
        this.rectangle.x = _x;
    }

    draw() {
        this.drawShape(this.rectangle);
    }

    /**
     * get/set 属性
     * @param {*} key 
     * @param {*} value 
     */
    attr(key, value) {
        if (undefined != value) {
            let isOk = this.attrBase(key, value);
            !isOk && (isOk = this.attrStyle(key, value)); 

            if (isOk) {
                const fil = this.fill;
                this.draw();
            }
        }
        else {
            let result = this.attrBase(key);
            undefined == result && (result = this.attrStyle(key));
            return result;
        }
    }

    // /**
    //  * Draws a rectangle shape.
    //  *
    //  * @param {number} x - The X coord of the top-left of the rectangle
    //  * @param {number} y - The Y coord of the top-left of the rectangle
    //  * @param {number} width - The width of the rectangle
    //  * @param {number} height - The height of the rectangle
    //  * @return {PIXI.DrawBaseItem} This DrawBaseItem object. Good for chaining method calls
    //  */
    // drawRect(x, y, width, height)
    // {
    //     return this.drawShape(new Rectangle(x, y, width, height));
    // }

    // /**
    //  * Draw a rectangle shape with rounded/beveled corners.
    //  *
    //  * @param {number} x - The X coord of the top-left of the rectangle
    //  * @param {number} y - The Y coord of the top-left of the rectangle
    //  * @param {number} width - The width of the rectangle
    //  * @param {number} height - The height of the rectangle
    //  * @param {number} radius - Radius of the rectangle corners
    //  * @return {PIXI.DrawBaseItem} This DrawBaseItem object. Good for chaining method calls
    //  */
    // drawRoundedRect(x, y, width, height, radius)
    // {
    //     return this.drawShape(new RoundedRectangle(x, y, width, height, radius));
    // }
}